package com.cloudcc.mobile.presenter;

import com.cloudcc.cloudframe.bus.BaseEvent;
import com.cloudcc.cloudframe.bus.EventEngine;
import com.cloudcc.cloudframe.util.ConnectivityUtils;
import com.cloudcc.mobile.AppContext;
import com.cloudcc.mobile.manager.RunTimeManager;

/**
 * 控制器父类
 * 
 * @author wangzhiqiang
 * @date 2015-7-24 上午11:00:07
 * 
 */
public class BasePresenter {
	private String mEns = RunTimeManager.getInstance().getlanguage();
	/**
	 * 是否正在注册在ui
	 */
	protected boolean isRegistering = true;

	/**
	 * 检测当前是否可以联网
	 * 
	 * @param event
	 * @return
	 */
	public boolean checkNoNet(BaseEvent event) {
		boolean hasInternet = ConnectivityUtils.hasInternet(AppContext
				.getInstance());
		if (hasInternet) {
			return false;
		} else {
			event.setOk(false);

if ("en".equals(mEns)) {
	event.setMessage("No network connection detected");
	}else{
		event.setMessage("未检测到网络连接");
}
			
			event.setStatusCode(BaseEvent.NET_NO_NETWORK);
			EventEngine.post(event);
			return true;
		}
	}

	/**
	 * 注销 从UI
	 */
	public void uregister() {
		isRegistering = false;
	}

}
